package com.service;

import com.bean.Student;
import com.dao.SrudentDao;
import com.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;

public class StudentService implements StudentServiceIf{
    private SrudentDao dao = new SrudentDao();

    @Override
    public Boolean login(String username, String psw) {
        HashMap<String, String> hm = dao.login();
        if (hm.containsKey(username)&&hm.get(username).equals(psw)){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public Boolean newUser(String username,String psw){
        int i = dao.newUser(username, psw);
        if (i==0){
            return false;
        }else {
            return true;
        }
    }

    @Override
    public HashMap<String, Student> findStudent() {
        return dao.findStudent();
    }

    @Override
    public Boolean delete(String id) {
        int i = dao.delete(id);
        if (i==0){
            return false;
        }else{
            return true;
        }
    }

    @Override
    public Boolean update(Student student) {
        int i = dao.update(student);
        if (i==0){
            return false;
        }else {
            return true;
        }
    }
}
